package lib.bone.nepudata.domain.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.Hibernate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;
import java.util.Objects;

/**
 * @Author : kindear
 * @Date : 2021-12-24
 * 论文登记成果
 */

/**
 * Q: 论文有没有什么唯一识别代码之类的？
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "nepu_paper")
@EntityListeners(AuditingEntityListener.class)
@GenericGenerator(name = "jpa-uuid", strategy = "uuid")
public class NepuPaper {
    @Id
    @GeneratedValue(generator = "jpa-uuid")
    @ApiModelProperty(value = "论文/成果ID",name = "id")
    String id;

    @ApiModelProperty("周期ID")
    @Column(name = "cycle_id")
    String cycleId;

    /**
     * 对应论文词典ID
     */
    @ApiModelProperty(value = "论文/成果词典ID",notes = "")
    @Column(name = "paper_dict_id")
    String paperDictId;

    /** 论文标题 @TIPS 赵春雨 **/
    @ApiModelProperty("论文标题")
    @Column(name = "paper_title")
    String paperTitle;

    /**
     * 第一署名单位
     */
    @ApiModelProperty(value = "第一署名单位")
    @Column(name = "first_signature_unit")
    String firstSignatureUnit;

    /**
     * 论文发表时间
     */
    @ApiModelProperty(value = "论文发表时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @Column(name = "paper_publication_time")
    Date paperPublicationTime;

    /**
     * 第一作者
     */
    @ApiModelProperty(value = "第一作者")
    @Column(name = "first_author")
    String firstAuthor;

    /**
     * 第一作者 ID
     */
    @ApiModelProperty(value = "第一作者ID",notes = "缺省值0代表不在教工系统中")
    @Column(name = "first_author_id")
    Long firstAuthorId;

    /**
     * 第二作者
     */
    @ApiModelProperty(value = "第二作者")
    @Column(name = "second_author")
            String secondAuthor;

    /**
     * 第二作者ID
     */
    @ApiModelProperty(value = "第二作者ID",notes = "缺省值0代表不在教工系统中")
    @Column(name = "second_author_id")
    Long secondAuthorId;


    /**
     * 论文总字数
     */
    @ApiModelProperty(value = "论文总字数")
    @Column(name = "paper_total_number",scale = 2)
    Double paperTotalNumber;

    /**
     * 负责人总字数
     */
    @ApiModelProperty(value = "负责人总字数")
    @Column(name = "charge_total_number",scale = 2)
    Double chargeTotalNumber;

    /**
     * 期刊名称
     */
    @ApiModelProperty(value = "期刊名称")
    @Column(name = "journal_name")
    String journalName;

    /**
     * 刊号
     */
    @ApiModelProperty(value = "刊号")
    @Column(name = "issue_number")
    String issueNumber;


    /**
     * 指导教师身份
     */
    @Column(name = "teacher_identity")
    @ApiModelProperty(value = "指导教师身份",notes = "0 无 1 第二作者 2 通讯作者")
    Integer teacherIdentity;

    /**
     * 分配所得工作量
     */
    @ApiModelProperty(value = "工作量",notes = "")
    @Column(name = "workload",scale = 2)
    Double workload;

    @ApiModelProperty(value = "论文状态",notes = "1保留 0删除")
    @Column(name = "status")
    Integer status;



    @CreatedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录创建时间",name = "createdTime")
    @Column(name = "created_time")
    private Date createdTime;
    @LastModifiedDate
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    @ApiModelProperty(value = "记录更新时间",name = "updatedTime")
    @Column(name = "updated_time")
    private Date updatedTime;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) return false;
        NepuPaper nepuPaper = (NepuPaper) o;
        return id != null && Objects.equals(id, nepuPaper.id);
    }

    @Override
    public int hashCode() {
        return getClass().hashCode();
    }
}
